package net.lab1024.sa.admin.module.business.outbound.controller;

import net.lab1024.sa.admin.module.business.outbound.domain.form.OutboundInfoAddForm;
import net.lab1024.sa.admin.module.business.outbound.domain.form.OutboundInfoQueryForm;
import net.lab1024.sa.admin.module.business.outbound.domain.form.OutboundInfoUpdateForm;
import net.lab1024.sa.admin.module.business.outbound.domain.vo.OutboundInfoVO;
import net.lab1024.sa.admin.module.business.outbound.service.OutboundInfoService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * 出库单 Controller
 *
 * @Author zzx
 * @Date 2025-08-13 15:17:33
 * @Copyright zzx
 */

@RestController
@Tag(name = "出库单")
public class OutboundInfoController {

    @Resource
    private OutboundInfoService outboundInfoService;

    @Operation(summary = "分页查询 @author zzx")
    @PostMapping("/outboundInfo/queryPage")
    @SaCheckPermission("outboundInfo:query")
    public ResponseDTO<PageResult<OutboundInfoVO>> queryPage(@RequestBody @Valid OutboundInfoQueryForm queryForm) {
        return ResponseDTO.ok(outboundInfoService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author zzx")
    @PostMapping("/outboundInfo/add")
    @SaCheckPermission("outboundInfo:add")
    public ResponseDTO<String> add(@RequestBody @Valid OutboundInfoAddForm addForm) {
        return outboundInfoService.add(addForm);
    }

    @Operation(summary = "更新 @author zzx")
    @PostMapping("/outboundInfo/update")
    @SaCheckPermission("outboundInfo:update")
    public ResponseDTO<String> update(@RequestBody @Valid OutboundInfoUpdateForm updateForm) {
        return outboundInfoService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author zzx")
    @PostMapping("/outboundInfo/batchDelete")
    @SaCheckPermission("outboundInfo:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return outboundInfoService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author zzx")
    @GetMapping("/outboundInfo/delete/{outboundId}")
    @SaCheckPermission("outboundInfo:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long outboundId) {
        return outboundInfoService.delete(outboundId);
    }

    @Operation(summary = "详情 @author zzx")
    @GetMapping("/outboundInfo/detail/{outboundId}")
    @SaCheckPermission("outboundInfo:detail")
    public ResponseDTO<OutboundInfoVO> getDetail(@PathVariable Long outboundId) {
        return outboundInfoService.detail(outboundId);
    }

    @Operation(summary = "详情 @author zzx")
    @GetMapping("/outboundInfo/exportExcl/{outboundId}")
    @SaCheckPermission("outboundInfo:exportExcl")
    public ResponseDTO<String> exportExcl(@PathVariable Long outboundId) {
        return outboundInfoService.exportExcl(outboundId);
    }

}
